package vivace.model;

/**
 * Enum defining the different possible actions that can
 * be performed within the application. It is used to prevent
 * unneccessary redrawing of parts of the GUI that hasn't been
 * affected by a change in the model.
 */
public enum Action {

	// App model actions
	ALL_CLOSED (false), 
	PROJECT_ADDED (false), 
	PROJECT_CLOSED (false), 
	PROJECT_SWITCHED (false),
	
	// Project model actions
	DEVICE_CHANGED(false),
	SAVED (false), 
	TRACK_ADDED (true), 
	TRACK_REMOVED (true),
	TRACK_PARAMETERS_EDITED (true),
	TRACK_MOVED(true),
	SEQUENCER_STARTED (false), 
	SEQUENCER_STOPPED (false), 
	SEQUENCER_POSITION_CHANGED (false), 
	HISTORY_CHANGED (false),
	PROJECT_OPENED (false),
	PROJECT_PLAYED (false), 
	PROJECT_STOPPED (false),
	RECORDING_FINISHED (true),        
	TIMESIGNATURE_ADDED (true),
	TIMESIGNATURE_REMOVED(true),        
	TIMESIGNATRUE_EDIT(true),
	NOTE_ADDED(true),
	NOTE_REMOVED(true),
	NOTE_MOVED(true),
	NOTE_RESIZED(true),
	EVENT_PARAMETER_CHANGED(true),
	TEMPOCHANGE_DELETED(true),
	TEMPOTIME_CHANGED(true),
	TEMPOCHANGE_CREATED(true),
	TEMPO_CHANGED(true),
	
	// UI model actions
	PERSPECTIVE_CHANGED (false),
	EVENT_PROPERTY_CHANGED (false),
	TOOL_CHANGED (false),
	ZOOMLEVEL_CHANGED (false),
	TRACK_SELECTION_CHANGED (false),
	NOTE_SELECTION_CHANGED (false),
	SNAP_CHANGED (false),
	DISCOMODE_CHANGED (false),
	RESOLUTION_CHANGED (false);

	private boolean isEdit;
	
	/*
	 * Private constructor. Argument isEdit specifies if the action results in
	 * saving the state.
	 */
	private Action(boolean isEdit) {
		this.isEdit = isEdit;
	}
	
	/**
	 * Returns true if the action should result in saving the previous state.
	 * @return
	 */
	public boolean isEdit() {
		return isEdit;
	}
	
	/**
	 * Returns a string representation 
	 */
	public String toString() {
        return lib.Texter.Text.getText(name());
    }
}
